home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / lu62 / novell / curhscb.c < prev    next >
C/C++ Source or Header  |  1996-07-10  |  4KB  |  118 lines

  1. #include <include.h>
  2. #include <string.h>
  3. #include <malloc.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6.  
  7.  extern void *hscb_lst_ptr;
  8.  extern void *nau_lst_ptr;
  9.  extern int totalNau;
  10.  
  11.  
  12.  unsigned long findnau (void *np, void **naupp);
  13.  struct hscb *fndhsad(char *);
  14.  
  15. /*********************CRHSCB********************************************/
  16.    struct hscb *crhscb( char *mylu,char *partlu )
  17.         {
  18.             unsigned long rc;
  19.             struct hscb *whscb,*whscbq;
  20.             struct nau *wnau;
  21.  
  22.  
  23.                whscb = calloc (1,sizeof(struct hscb));
  24.                if (whscb == NULL )
  25.                     return (NULL);
  26.                rc = findnau ( mylu ,&wnau);
  27.                if (rc != 0)
  28.                     return (NULL);
  29.                whscb->naup = wnau;
  30.                memcpy (whscb->hslunam, partlu, 8);
  31.                wnau -> link = whscb;
  32.                whscb -> cor = whscb;
  33.                rc = findnau ( partlu,&wnau);
  34.                if (rc != 0)
  35.                     return (NULL);
  36.                memcpy( whscb -> part_net_ad, wnau -> net_ad, 6);
  37.                if (hscb_lst_ptr == NULL )
  38.                     hscb_lst_ptr = whscb;
  39.                else
  40.                     {
  41.                         whscbq = hscb_lst_ptr;
  42.                         while (whscbq -> next != NULL )
  43.                                 whscbq = whscbq -> next;
  44.                         whscbq -> next = whscb;
  45.                     }
  46.               return (whscb);
  47.          }
  48.   /*************************FINDHSCB********************************/
  49.  
  50.     struct hscb *findhscb(char *ccor )
  51.                  {
  52.                     struct hscb *whscb;
  53.                         whscb = hscb_lst_ptr;
  54.                         if (whscb -> cor == ccor)
  55.                                 return(whscb);
  56.                         whscb = whscb -> next;
  57.                         do {
  58.                 if (whscb ->cor == ccor)
  59.                                     return (whscb);
  60.                              whscb = whscb -> next;
  61.                            } while (whscb != NULL );
  62.                        return (NULL);
  63.               }
  64.   /*************************FNDHSAD********************************/
  65.  
  66.         struct hscb *fndhsad( char *p_ad )
  67.                  {
  68.                     struct hscb *whscb;
  69.  
  70.                         whscb = hscb_lst_ptr;
  71.                         while ( whscb != NULL ){
  72.                               if( (memcmp (whscb -> part_net_ad,p_ad,6)) == 0)
  73.                                        break;
  74.                               whscb = whscb -> next;
  75.                         }
  76.                        return (whscb);
  77.                  }
  78.  /**************************DELHSCB************************************/
  79.  
  80.     int delhscb (struct hscb *whscb)
  81.                  {
  82.                     struct hscb *whscbq;
  83.                         whscbq = hscb_lst_ptr;
  84.                         if (whscbq == whscb)
  85.                                hscb_lst_ptr = NULL;
  86.                         do {
  87.                               if ( whscbq -> next == whscb)
  88.                                     {
  89.                     whscbq -> next = whscb -> next;
  90.                     free(whscb);
  91.                     return 0;
  92.                                      }
  93.                               whscbq = whscbq -> next;
  94.                           } while ( whscbq != NULL );
  95.                return 0;
  96.                  }
  97.  /****************************FINDNAU***********************************/
  98.  
  99.        unsigned long findnau (char *np,struct nau **naupp)
  100.                {
  101.                  struct nau *naup;
  102.                  int i;
  103.  
  104.                      naup = nau_lst_ptr;
  105.                      i = 0;
  106.                      do {
  107.                           if (memcmp( np, naup -> name,8) == 0)
  108.                                 {
  109.                                     *naupp = naup;
  110.                     return 0;
  111.                                 }
  112.                           naup ++;
  113.                           i++;
  114.                        } while ( i <= totalNau );
  115.                     return (i);
  116. }
  117.   /******************************THE END *******************************/
  118.